var Tower = cc.MenuItemImage.extend({
    _index : -1,
    _series : 0,
    _canFire : true,
    _point : cc.p(0,0),
    // init from file data
    _rType : 0,
    _fireRange : 0,
    _fireTime : 0,
    _bulletRes : "",
    _updateSpeed : [],
    // for init bullet
    _power : 0,
    _speed : 0,
    // some buffer
    _bullets : [],
    ///////////////////////////////////////////////////////////
    ctor : function( filename,towerData ){//series,power,speed,fireRange,fireTime,bulletRes
        this._super(filename);
        this._rType = towerData.t;
        this._fireRange = towerData.fr;
        this._fireTime = towerData.ft;
        this._bulletRes = towerData.bRes;
        for( var i=0;i<towerData.su.length;i++){
            this._updateSpeed.push(towerData.su[i]);
        }
        // for bullet
        this._power = towerData.pw;
        this._speed = towerData.sp;
    },
    onEnter:function () {
        this._super();
    },
    onExit : function(){
        this._super();
    },
    //////// index for splice from manager buffer: _towers ///////
    setIndex : function(index){
        this._index=index;
    },
    getIndex : function(){
        return this._index;
    },
    getUpdateSpeed : function(){
        if( this._series<this._updateSpeed.length ){
            return this._updateSpeed[this._series];
        }else{
            cc.log("full series");
            return -1;
        }
    },
    setPoint : function(x,y){
        this._point.x=x,this._point.y=y;
    },
    setPoint : function(point){
        this._point=point;
    },
    getPoint : function(){
        return this._point;
    },
    getBulletFromBuffer : function(){
        for (var i=0;i<this._bullets.length;++i){
            var bullet = this._bullets[i];
            if(!bullet.isVisible()){
                cc.log("get bullet from buffer");
                return bullet;
            }
        }
        return null;
    },
    updateSeries : function(){
        ++this._series;
        this.setScale(1.2);
    }
});
